const express = require("express");
const app = express();
const port = 8081;

// 使用中间件解析JSON格式的请求体
app.use(express.json());

// 定义路由和处理程序
app.get("/getInfo", (req, res) => {
  const info = {
    msg: "操作成功",
    code: 200,
    permissions: ["*:*:*"],
    roles: ["admin"],
    user: {
      createBy: "admin",
      createTime: "2021-05-26 18:56:28",
      updateBy: null,
      updateTime: null,
      remark: "管理员",
      params: {
        "@type": "java.util.HashMap",
      },
      userId: 1,
      deptId: 103,
      userName: "admin",
      nickName: "总公司",
      email: "ry@163.com",
      phonenumber: "15888888888",
      sex: "1",
      avatar: "",
      password: "$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2",
      status: "0",
      delFlag: "0",
      loginIp: "127.0.0.1",
      loginDate: "2024-02-04T10:47:22.692+08:00",
      dept: {
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
        params: {
          "@type": "java.util.HashMap",
        },
        deptId: 103,
        parentId: 101,
        ancestors: "0,100,101",
        deptName: "研发部门",
        orderNum: 1,
        leader: "若依",
        phone: null,
        email: null,
        status: "0",
        delFlag: null,
        parentName: null,
        children: [],
      },
      roles: [],
      roleIds: null,
      postIds: null,
      roleId: null,
      admin: true,
    },
  };
  res.json(info); // 返回JSON格式的对象
});
app.get("/getRouters", (req, res) => {
  const info = {
    msg: "操作成功",
    code: 200,
    data: [
      {
        name: "System",
        path: "/system",
        hidden: false,
        redirect: "noRedirect",
        component: "Layout",
        alwaysShow: true,
        meta: {
          title: "系统管理",
          icon: "system",
          noCache: false,
          link: null,
        },
        children: [
          {
            name: "User",
            path: "user",
            hidden: false,
            component: "system/user/index",
            meta: {
              title: "用户管理",
              icon: "user",
              noCache: false,
              link: null,
            },
          },
          {
            name: "Role",
            path: "role",
            hidden: false,
            component: "system/role/index",
            meta: {
              title: "角色管理",
              icon: "peoples",
              noCache: false,
              link: null,
            },
          },
          {
            name: "Menu",
            path: "menu",
            hidden: false,
            component: "system/menu/index",
            meta: {
              title: "菜单管理",
              icon: "tree-table",
              noCache: false,
              link: null,
            },
          },
        ],
      },
    ],
  };
  res.json(info); // 返回JSON格式的对象
});

// 启动服务器
app.listen(port, () => {
  console.log(`Server is running on http://localhost:${port}`);
});
